package com.huawei.cloud.phone.management.application.phone;

import com.huawei.cloud.phone.management.application.pkg.dto.PhoneInfoDTO;
import com.huawei.cloud.phone.management.domain.phone.PhoneDomainService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@AllArgsConstructor
public class PhoneServiceImpl implements PhoneService {
    private final PhoneDomainService phoneDomainService;

    @Override
    public void syncPhoneInfo(@NonNull PhoneInfoDTO phoneInfoDTO) {
        phoneInfoDTO.getServerIds().forEach(phoneDomainService::syncPhonesFromManager);
        phoneInfoDTO.getPhoneIds().forEach(phoneDomainService::syncPhoneFromManager);
    }
}
